<?php
session_start();
require_once( 'configs/config.php' );
require_once( 'lib/db.php' );

if( $_SERVER[ 'REQUEST_METHOD' ] == 'GET' )
{
	echo 'No post.';
	exit;
}

$formFields = array( 'FirstName', 'LastName', 'Email', 'PhoneNumber' ,'Password');

foreach( $formFields as $field )
{
	$form[ $field ] = htmlentities( trim( $_POST[ $field ] ), ENT_QUOTES );
	$form[ $field ] = $db->escape( $form[ $field ] );
}

// Insert into the database
$query = 'INSERT INTO users ( FirstName, LastName, Email, PhoneNumber, Password ) VALUES ( \'' .  $form['FirstName'] . '\', \'' . $form['LastName'] . '\', \'' . $form['Email'] . '\', \'' . $form['PhoneNumber'] . '\', MD5(' . $form['Password'] . ' ) )';

if( $db->query( $query ) )
{
	echo 'Submitted.';
	$db->debug();
	include_once('addAccount.php');
}
else
{
	echo 'Error';
}
?>